package cn.accp.war;

import java.util.Random;

import cn.accp.war.baseEntity.Hero;
import cn.accp.war.baseEntity.Monster;
import cn.accp.war.baseEntity.entity.Barbarian;
import cn.accp.war.baseEntity.entity.LandMonster;
import cn.accp.war.baseEntity.entity.Magician;
import cn.accp.war.baseEntity.entity.Ranger;
import cn.accp.war.baseEntity.entity.SeaMonster;
import cn.accp.war.baseEntity.entity.SkyMonster;

public class Game {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Random random = new Random();
		Game game = new Game();
		Monster monster = game.creatMonster(random.nextInt(3) + 1);
		Hero hero = game.creatHero(random.nextInt(3) + 1, "王者荣耀", 120);
		game.battle(hero, monster);
	}

	public void battle(Hero hero, Monster monster) {
		monster.attack();
		hero.attack();
		if (hero.getMagic() > monster.getPower()) {
			System.out.println(hero.getName() + "战胜了" + monster.getName());
		} else {
			System.out.println(hero.getName() + "在跟" + monster.getName()
					+ "的战斗中阵亡了！");
		}
	}

	public Monster creatMonster(int choice) {
		Monster monster = null;
		switch (choice) {
		case 1:
			monster = new LandMonster();
			break;
		case 2:
			monster = new SkyMonster();
			break;
		case 3:
			monster = new SeaMonster();
			break;
		default:
			break;
		}
		return monster;
	}

	public Hero creatHero(int choice, String name, int magic) {
		Hero hero = null;
		switch (choice) {
		case 1:
			hero = new Magician(name, magic);
			break;
		case 2:
			hero = new Barbarian(name, magic);
			break;
		case 3:
			hero = new Ranger(name, magic);
			break;
		default:
			break;
		}
		return hero;
	}
}
